'''
@auther:zhongyingjie
@date:开发时间:2022/11/21 16:54
@file:run_all_testcases.PY
@desc:
'''
import allure
import os,shutil  # shutil 操作文件更高级
import pytest
# current_path = os.path.dirname(os.path.abspath(__file__))
# json_report = os.path.join(current_path,'reports','json_report')
# html_report = os.path.join(current_path,'reports','html_report')
json_report = 'D:\\python_py\\pytest_demo\\reports\\json_report'
html_report = 'D:\\python_py\\pytest_demo\\reports\\html_report'

if os.path.isdir(json_report):
    shutil.rmtree(json_report) # 递归删除文件 先删除已经有的目录文件然后再生成报告

pytest.main(["-v", "--alluredir=%s"%json_report ])

os.system("allure generate %s -o %s --clean" %(json_report,html_report))
# python 打开cmd执行dos命令